1 Imports System.IO
2 Public Class frmEdit
3
4     Dim globalpath As String
5
6 #Region
"Controlbox"
7
8     Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
9         Me.Close()
10     End Sub
11
12 #End Region
13
14 #Region
" Procedures "
15
16     Public Sub Edit_Product(ByRef Pname As String, ByRef Pprice As String, ByRef Ppath As String, ByRef Pimg As String)
17         Try
18             Dim path As String = Application.StartupPath &
"\Burger\" & Ppath & ".txt"
19             globalpath = path
20             Dim reader As New StreamReader(path)
21             Pname = reader.ReadLine
22             lblEditname.Text = "
Edit: " & Pname
23             Pprice = reader.ReadLine
24             Pimg = reader.ReadLine
25             reader.Close()
26         Catch ex As Exception
27         End Try
28     End Sub
29
30     Public Sub Edit_Product1(ByRef Pname As String, ByRef Pprice As String, ByRef Ppath As String, ByRef Pimg As String)
31         Try
32             Dim path As String = Application.StartupPath & "
\Drink\" & Ppath & ".txt"
33             globalpath = path
34             Dim reader As New StreamReader(path)
35             Pname = reader.ReadLine
36             lblEditname.Text = "
Edit: " & Pname
37             Pprice = reader.ReadLine
38             Pimg = reader.ReadLine
39             reader.Close()
40         Catch ex As Exception
41         End Try
42     End Sub
43
44     Public Sub Edit_Product2(ByRef Pname As String, ByRef Pprice As String, ByRef Ppath As String, ByRef Pimg As String)
45         Try
46             Dim path As String = Application.StartupPath & "
\Special\" & Ppath & ".txt"
47             globalpath = path
48             Dim reader As New StreamReader(path)
49             Pname = reader.ReadLine
50             lblEditname.Text = "
Edit: " & Pname
51             Pprice = reader.ReadLine
52             Pimg = reader.ReadLine
53             reader.Close()
54         Catch ex As Exception
55         End Try
56     End Sub
57
58     Private Sub Save_Product()
59         If txtPname.Text.Trim = String.Empty Then
60             MessageBox.Show("
Product Name cannot be empty.", "Invalid Product Name", MessageBoxButtons.OK, MessageBoxIcon.Warning)
61             txtPname.Focus()
62             txtPname.SelectAll()
63         ElseIf txtPprice.Text.Trim = String.Empty Then
64             MessageBox.Show("
Product Price cannot be empty.", "Invalid Product Price", MessageBoxButtons.OK, MessageBoxIcon.Warning)
65             txtPprice.Focus()
66             txtPprice.SelectAll()
67         Else
68             Dim writer As New StreamWriter(globalpath)
69             writer.WriteLine(txtPname.Text)
70             writer.WriteLine(txtPprice.Text)
71             writer.WriteLine(txtImg.Text)
72             writer.Close()
73             Me.Close()
74             frmMenu.auto()
75         End If
76     End Sub
77
78 #End Region
79
80     Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
81         Me.Close()
82     End Sub
83
84     Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
85         Save_Product()
86     End Sub
87
88     Private Sub txtImg_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtImg.TextChanged
89         PicImg.ImageKey = txtImg.Text
90     End Sub
91
92     Private Sub frmEdit_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
93
94     End Sub
95 End Class


Gõ tìm kiếm nhanh...